package com.xuetang9.t9.hotel.mapper;

import com.xuetang9.t9.hotel.beans.TableType;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;


/**桌子类型接口
 * @author ChinaHp
 */
public interface ITableTypeMapper {
    /**
     * 获取所有
     * @return
     */
    @Select("select * from tableType")
    List<TableType> queryAll();

    /**
     * 添加
     * @param tableType
     * @return
     */
    @Insert("insert into tableType (name,diners,waitTime) value (#{name},#{diners},#{waitTime})")
    int add(TableType tableType);

    /**
     * 通过id获取
     * @param id
     * @return
     */
    @Select("select * from tableType where id = #{id}")
    TableType select(@Param("id") int id);

    /**
     * 修改
     * @param tableType
     * @return
     */
    @Update("update tableType set name=#{name},diners=#{diners},waitTime=#{waitTime} where id = #{id}")
    int update(TableType tableType);

    /**
     * 删除
     * @param id
     * @return
     */
    @Delete("delete from TableType where id = #{id}")
    int delete(int id);


    @Select("select * from tableType")
    @Results(value = {
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "id",property = "arrangings",many = @Many(select = "com.xuetang9.t9.hotel.mapper.ArrangingMapper.selectByTodayTableAll",fetchType = FetchType.EAGER))
    })
    List<TableType> selectByArr();

    /**
     * 通过name获取
     * @param name
     * @return
     */
    @Select("select * from tableType where name = #{name}")
    TableType getByName(@Param("name") String name);
}
